# coding=utf-8

import os
import configparser
import redis

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

main_cf = configparser.ConfigParser()
main_cf.read(BASE_DIR + '/../conf/main.ini')

ALLOWED_HOSTS = ['*']

mysql_host = main_cf.get('db', 'uic_db_host')
mysql_port = main_cf.get('db', 'uic_db_port')
mysql_user = main_cf.get('db', 'uic_db_user')
mysql_pwd = main_cf.get('db', 'uic_db_pwd')
mysql_name = main_cf.get('db', 'uic_db_name')

redis_host = main_cf.get('redis', 'redis_db_host')
redis_port = main_cf.get('redis', 'redis_db_port')
redis_pwd = main_cf.get('redis', 'redis_db_pwd')
redis_db_name = main_cf.get('redis', 'redis_db_name')

magic_redis = redis.StrictRedis(host=redis_host,
                                port=redis_port,
                                db=redis_db_name,
                                password=redis_pwd)

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'HOST': mysql_host,
        'PORT': mysql_port,
        'NAME': mysql_name,
        'USER': mysql_user,
        'PASSWORD': mysql_pwd,
        'OPTIONS': {'charset': 'utf8'},
    }
}

